package CrowdCountingMVC.CCView.CCShow;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.IOException;

public class DisplayFrame extends JFrame {

    public File displayImage(JLabel imageLabel, File imageFile) {
        Image image = null;
        try {
            image = ImageIO.read(imageFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        imageLabel.setText("");
        imageToLable(imageLabel, image);
        return imageFile;
    }


    public void imageToLable(JLabel imageLabel, Image image) {
        ImageIcon imageIcon = new ImageIcon(image);
        imageLabel.setIcon(imageIcon);
        imageLabel.repaint();
        validate();
        repaint();
    }

    public void displayText(JLabel textLabel, String text) {
        textLabel.setText(text);
        textLabel.repaint();
        validate();
        repaint();
    }

}
